<%@page isELIgnored="false" import="java.net.*" %>
<%@taglib prefix="tiles" uri="struts-tiles" %>
<%@taglib prefix="html" uri="struts-html" %>
<%@taglib prefix="bean" uri="struts-bean" %>
<%@taglib prefix="c" uri="jstl" %>
<%@taglib prefix="fn" uri="jstl-fn" %>
<%try{
%>
					
<%@page import="com.mastercard.assets.web.util.to.UserLogin"%><div id="bodyContent">
						<h1>Crear Forma</h1>
						
						<html:form enctype="multipart/form-data" action='/FormasAgregarRegistrar' method='post'>
						<html:hidden property="operacion" />
						<html:hidden property="page" value="2" />
						<div onclick="location.href='${URLBase}Flujos.do';" style="display: inline; color: blue; font-size: 12px;" onmouseover="this.style.textDecoration='underline';this.style.cursor='pointer';" onmouseout="this.style.textDecoration='none';this.style.cursor='default';" >Flujos</div><div style="display: inline; color: black; font-size: 12px;" > > </div>
						<div style="display: inline; color: black; font-size: 12px;"  >Crear Nueva Forma</div>
						<br/>
						<br/>
						<center>
						<div class='errors'>
						<html:errors/>
						<br/>
						${UserLogin.messageError}
						</div>
						
						<script type="text/javascript">
							function addNewExit( )
							{
								// crea el elemento del div
								divNew = document.createElement( "div" ) ;
								tableNew = document.createElement( "table" ) ;
								tableNew.setAttribute( "width" , "100%" ) ;
								tableNew.setAttribute( "cellpadding", "1" ) ;
								tableNew.setAttribute( "cellspacing" , "1" ) ;
								trNew = document.createElement( "tr" ) ;
								tdNew = document.createElement( "td" ) ;
								textNew = document.createTextNode( '<bean:message key="com.mastercard.assets.web.modules.forms.add.labels.NombreSalidas" />' ) ;
								tdNew.appendChild( textNew ) ;
								trNew.appendChild( tdNew ) ;
								tdNew = document.createElement( "td" ) ;
								textNew = document.createTextNode( '<bean:message key="com.mastercard.assets.web.modules.forms.add.labels.DescripcionSalidas" />' ) ;
								tdNew.appendChild( textNew ) ;
								trNew.appendChild( tdNew ) ;
								tableNew.appendChild( trNew ) ;
								tdNew = document.createElement( "td" ) ;
								textNew = document.createTextNode( ' ' ) ;
								tdNew.appendChild( textNew ) ;
								trNew.appendChild( tdNew ) ;

								// segundo renglon
								trNew = document.createElement( "tr" ) ;
								tdNew = document.createElement( "td" ) ;
								textElem = document.createElement( "input" ) ;
								textElem.setAttribute("type","text");
								textElem.setAttribute("name","nombreSalidas");
								textElem.setAttribute("style","background-color: #CCC ;border-left: 1px solid black ;border-top: 1px solid black ;border-bottom: 2px solid black ;border-right: 2px solid black ;color: black ;font-size: 11px ;width: 120px ;");
								tdNew.appendChild( textElem ) ;
								trNew.appendChild( tdNew ) ;
								tdNew = document.createElement( "td" ) ;
								textElem = document.createElement( "input" ) ;
								textElem.setAttribute("type","text");
								textElem.setAttribute("name","descripcionSalidas");
								textElem.setAttribute("style","background-color: #CCC ;border-left: 1px solid black ;border-top: 1px solid black ;border-bottom: 2px solid black ;border-right: 2px solid black ;color: black ;font-size: 11px ;width: 120px ;");
								tdNew.appendChild( textElem ) ;
								trNew.appendChild( tdNew ) ;
								tdNew = document.createElement( "td" ) ;
								imgNew = document.createElement( "img" ) ;
								imgNew.setAttribute( "src" , "images/btnRest.jpg" ) ;
								imgNew.setAttribute( "onclick" , "document.getElementById( 'SalidasCol' ).removeChild( this.parentNode.parentNode.parentNode.parentNode );" ) ;
								tdNew.appendChild( imgNew ) ;
								trNew.appendChild( tdNew ) ;

								tableNew.appendChild( trNew ) ;

								divNew.appendChild( tableNew ) ;
								
								// taam el td
								tdSalidas = document.getElementById( 'SalidasCol' ) ;

								tdSalidas.appendChild( divNew ) ;
							}
						</script>
						
						<table class="TablaCatalogosNuevoTipoCuenta">
							<thead>
								<tr>
									<th>
										Nueva forma
									</td>
								</tr>
							</thead>
							<tr>
								<td>
									<br/>
									<table class='TablaCatalogosFields' border="0">
										<tr>
											<td class='TDLabel'>
												<bean:message key="com.mastercard.assets.web.modules.forms.add.labels.Nombre" />
											</td>
											<td class='TDField'>
												<html:text property="nombre" styleClass='TextField' />
											</td>
										</tr>
										<tr>
											<td class='TDLabel'>
												<bean:message key="com.mastercard.assets.web.modules.forms.add.labels.Descripcion" />
											</td>
											<td class='TDField'>
												<html:text property="descripcion" styleClass='TextField' />
											</td>
										</tr>
										<tr>
											<td colspan="2" class='TDField'>
												<bean:message key="com.mastercard.assets.web.modules.forms.add.labels.Salidas" /> &nbsp; &nbsp; &nbsp;<html:img src="images/btnAdd.gif" onclick="addNewExit( )" />
											</td>
										</tr>
										<tr>
											<td colspan="2" id="SalidasCol">
<c:set var="SalidasLength" value="${fn:length(FormasAgregarForm.nombreSalidas)}"/>
<c:if test="${SalidasLength eq 0}">
<!-- 
												<div>
													<table width="100%" border="0" cellpadding="1" cellspacing="1">
														<tr>
															<td>
																<bean:message key="com.mastercard.assets.web.modules.forms.add.labels.NombreSalidas" />
															</td>
															<td>
																<bean:message key="com.mastercard.assets.web.modules.forms.add.labels.DescripcionSalidas" />
															</td>
														</tr>
														<tr>
															<td>
																<html:text property="nombreSalidas" styleClass="TextField"/>
															</td>
															<td>
																<html:text property="descripcionSalidas" styleClass="TextField"/>
															</td>
														</tr>
													</table>
												</div>
 -->
</c:if>
<c:if test="${SalidasLength gt 0}">
<c:forEach items="${FormasAgregarForm.nombreSalidas}" var="salida" varStatus="salidaStatus" >
												<div>
													<table width="100%" border="0" cellpadding="1" cellspacing="1">
														<tr>
															<td>
																<bean:message key="com.mastercard.assets.web.modules.forms.add.labels.NombreSalidas" />
															</td>
															<td>
																<bean:message key="com.mastercard.assets.web.modules.forms.add.labels.DescripcionSalidas" />
															</td>
															<td>&nbsp;</td>
														</tr>
														<tr>
															<td>
																<html:text property="nombreSalidas" styleClass="TextFieldFormas" value="${FormasAgregarForm.nombreSalidas[salidaStatus.index]}"/>
															</td>
															<td>
																<html:text property="descripcionSalidas" styleClass="TextFieldFormas" value="${FormasAgregarForm.descripcionSalidas[salidaStatus.index]}"/>
															</td>
															<td><img src="images/btnRest.jpg" onclick="document.getElementById( 'SalidasCol' ).removeChild( this.parentNode.parentNode.parentNode.parentNode );" /></td>
														</tr>
													</table>
												</div>
</c:forEach>
</c:if>
											</td>
										</tr>
										<tr>
											<td class='TDField' colspan="2" >
												&nbsp;&nbsp;<bean:message key="com.mastercard.assets.web.modules.forms.add.labels.ArchivoForma" />
												<br/>
												&nbsp;&nbsp;<html:file property="archivoForma" styleClass='TextFieldFile' />
											</td>
										</tr>
										<tr>
											<td colspan='2' class='TDButton'>
												<html:submit value='Crear' styleClass="ButtonSubmit" />
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
						</center>
						</html:form>
					</div>
					<div id="footContent"></div>
<%}catch( Exception e )
{
out.print( e.getMessage( ) ) ;
}%>
<%
UserLogin user = ( UserLogin ) session.getAttribute( "UserLogin" ) ;
user.clearMessageError( ) ;
%>